package com.zcl.reflection;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @Description:
 * @author: zcl
 * @date: 2022/3/30  12:48
 */
public class ClassLoaderTest {

    @Test
    public void test2(){

        try {
            Properties pros = new Properties();
            FileInputStream fis = new FileInputStream("src\\com\\zcl\\reflection\\jdbc.properties");
            pros.load(fis);
            String user = pros.getProperty("user");
            String password = pros.getProperty("password");
            System.out.println(user);
            System.out.println(password);
        } catch (IOException ioException) {
            ioException.printStackTrace();
        }
    }

    @Test
    public void test3(){

        try {
            Properties pros = new Properties();
            ClassLoader classLoader = ClassLoaderTest.class.getClassLoader();
            InputStream is = classLoader.getResourceAsStream("jdbc1.properties");
            pros.load(is);
            String user = pros.getProperty("user");
            String password = pros.getProperty("password");
            System.out.println(user);
            System.out.println(password);
        } catch (IOException ioException) {
            ioException.printStackTrace();
        }

    }
}
